package com.itheima.service.db;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.Freeze;
import com.itheima.mapper.FreezeMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class FreezeServiceImpl implements FreezeService {
    @Autowired
    FreezeMapper freezeMapper;
    //保存冻结
    @Override
    public void saveFreeze(Freeze freeze) {
        //1.调用mapper
        freezeMapper.insert(freeze);
    }
    //根据用户ID查询用户冻结详情
    @Override
    public Freeze findFreezeUserByUserId(Long userId) {
        //1.创建查询条件
        QueryWrapper<Freeze> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        return freezeMapper.selectOne(wrapper);
    }
    //更新用户冻结信息
    @Override
    public void updateFreeze(Freeze freeze) {
        //1.创建查询条件
        QueryWrapper<Freeze> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",freeze.getUserId());
        freezeMapper.update(freeze,wrapper);
    }
}
